package com.star.carserviceapi.domain.result;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;

import com.star.carserviceapi.domain.CarFeatureInfo;
import com.star.carserviceapi.domain.result.base.BaseResult;

public class QryCarBrandResult
		extends
		BaseResult<LinkedHashMap<String, LinkedHashMap<String, QryCarBrandResult.Result>>> {

	private LinkedList<CarFeatureInfo> mCars = new LinkedList<CarFeatureInfo>();

	public LinkedList<CarFeatureInfo> getCars() {
		return mCars;
	}

	@Override
	protected void packing(
			LinkedHashMap<String, LinkedHashMap<String, QryCarBrandResult.Result>> data) {

		mCars.clear();
		
		for (Iterator<String> it = data.keySet().iterator(); it.hasNext();) {
			String key = it.next();

			CarFeatureInfo group = new CarFeatureInfo();
			group.setIndexName(key);
			group.setIsGroup(true);
			mCars.add(group);

			LinkedHashMap<String, QryCarBrandResult.Result> temp = data
					.get(key);

			for (Iterator<String> it2 = temp.keySet().iterator(); it2.hasNext();) {
				String carName = it2.next();

				Result result = temp.get(carName);
				
				
				CarFeatureInfo item = new CarFeatureInfo();
				
				item.setIsGroup(false);
				item.setBrand(carName);
				item.setThumbUrl(result.getThumb_url());
				item.setIsHot(result.isIs_hot());
				mCars.add(item);
			}
		}
	}

	class Result {
		/*
		 * { "name": [ "一汽大众-奥迪", "奥迪" ], "thumb_url":
		 * "http://www.vw.com.cn/zh/tools/constant_pool/_jcr_content/l100_framework_logo/file/_jcr_content./file.jpeg"
		 * , "is_hot": true }
		 */
		LinkedList<String> name;

		String thumb_url = "";

		boolean is_hot = false;

		public LinkedList<String> getName() {
			return name;
		}

		public void setName(LinkedList<String> name) {
			this.name = name;
		}

		public String getThumb_url() {
			return thumb_url;
		}

		public void setThumb_url(String thumb_url) {
			this.thumb_url = thumb_url;
		}

		public boolean isIs_hot() {
			return is_hot;
		}

		public void setIs_hot(boolean is_hot) {
			this.is_hot = is_hot;
		}
	}

}
